/*
============================================================================
 Name        : $(Basename)ReqHandler.cpp
 Author      : $(Author)
 Version     :
 Copyright   : $(Copyright)
 Description : Simple AO example to make an async request to the server.
============================================================================
*/

#include "$(Basename)Server.h"
#include "$(Basename)ReqHandler.h"
#include "$(Basename)Client.pan"

C$(Basename)ReqHandler* C$(Basename)ReqHandler::NewL()
	{
	C$(Basename)ReqHandler* self = NewLC();
	CleanupStack::Pop(self);
	return self;
	}

C$(Basename)ReqHandler* C$(Basename)ReqHandler::NewLC()
	{
	C$(Basename)ReqHandler* self = new(ELeave) C$(Basename)ReqHandler();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

C$(Basename)ReqHandler::C$(Basename)ReqHandler() : CActive(EPriorityStandard)
	{
	}

void C$(Basename)ReqHandler::ConstructL()
	{
	CActiveScheduler::Add(this);
	User::LeaveIfError(iSession.Connect());
	}

C$(Basename)ReqHandler::~C$(Basename)ReqHandler()
	{
	Cancel();
	iSession.Close();
	}

void C$(Basename)ReqHandler::RequestTime()
	{
	if(!IsActive())
		{
		iSession.RequestTime(iTime, iStatus);
		SetActive();
		}
	}

void C$(Basename)ReqHandler::CancelRequest()
	{
	Cancel();
	}

void C$(Basename)ReqHandler::RunL()
	{
	switch (iStatus.Int())
		{
		case E$(Basename)ServRequestTimeComplete:
			break;
		case KErrCancel:
			break;
		case KErrNotReady:
		default:
			User::Panic(K$(Basename)Client, EBadState);
		}
	CActiveScheduler::Stop(); // This stops the example.
	}

void C$(Basename)ReqHandler::DoCancel()
	{
	iSession.CancelRequestTime();
	}

TTime C$(Basename)ReqHandler::Time() const
	{
	return iTime;
	}
